/*
 * Copyright 2018- The Pixie Authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * SPDX-License-Identifier: Apache-2.0
 */

syntax = "proto3";

package px.stirling.rr;

// The request message containing the user's name.
message BPFEvents {
  repeated BPFEvent event = 1;
}

message BPFEvent {
  oneof event {
    PerfBufferEvent perf_buffer_event = 1;
    BPFArrayTableGetValueEvent array_table_get_value_event = 2;
    BPFMapGetValueEvent map_get_value_event = 3;
    BPFMapGetTableOfflineEvent map_get_table_offline_event = 4;
    BPFMapCapacityEvent map_capacity_event = 5;
    BPFStackTableGetStackAddrEvent get_stack_addr_event = 6;
    BPFStackTableGetAddrSymbolEvent get_addr_symbol_event = 7;
  }
}

message PerfBufferEvent {
  string name = 1;
  bytes data = 2;
}

message BPFArrayTableGetValueEvent {
  string name = 1;
  int32 idx = 2;
  bytes data = 3;
}

message BPFMapGetValueEvent {
  string name = 1;
  bytes key = 2;
  bytes value = 3;
}

// BPFMapGetTableOfflineEvent stores the number of table entries in "size".
// Then the recorder (or replayer) writes (reads) N key value pairs using BPFMapGetValueEvent.
message BPFMapGetTableOfflineEvent {
  string name = 1;
  int32 size = 2;
}

message BPFMapCapacityEvent {
  string name = 1;
  int32 capacity = 2;
}

message BPFStackTableGetStackAddrEvent {
  string name = 1;
  int32 stack_id = 2;
  repeated uint64 addr = 3;
}

message BPFStackTableGetAddrSymbolEvent {
  string name = 1;
  uint32 pid = 2;
  uint64 addr = 3;
  string symbol = 4;
}
